﻿using System;
using System.Data;
using System.Text;
using System.Data.SqlClient;
using Maticsoft.DBUtility;//Please add references
namespace EnterpriseFund.DAL
{
    public partial class QueryHREmpl
    {
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public DataSet GetList(string strWhere)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select FEntityNo,FEmplNo,FEmpName,FOfficeTel,FTelShortNo,FMobile,FMobShortNo,FEMail,FHomeTel,FHomeAddr,FSex,FIdNo,FBirthday,FNativePlace,FEduNo,FSchool,FSpecialty,FSeq,FPhoto,FDutyNo,FJob,FEmpStatus,FLeaveDate ");
            strSql.Append(" FROM t_HREmpl ");
            if (strWhere.Trim() != "")
            {
                strSql.Append(" where " + strWhere);
            }
            strSql.Append(" order by FEmpName");
            
            return DbHelperSQL.Query(strSql.ToString());
        }

        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public EnterpriseFund.Model.HREmpl DataRowToModel(DataRow row)
        {
            EnterpriseFund.Model.HREmpl model = new EnterpriseFund.Model.HREmpl();
            if (row != null)
            {
                if (row["FEntityNo"] != null)
                {
                    model.FEntityNo = row["FEntityNo"].ToString();
                }
                if (row["FEmplNo"] != null)
                {
                    model.FEmplNo = row["FEmplNo"].ToString();
                }
                if (row["FEmpName"] != null)
                {
                    model.FEmpName = row["FEmpName"].ToString();
                }
                if (row["FOfficeTel"] != null)
                {
                    model.FOfficeTel = row["FOfficeTel"].ToString();
                }
                if (row["FTelShortNo"] != null)
                {
                    model.FTelShortNo = row["FTelShortNo"].ToString();
                }
                if (row["FMobile"] != null)
                {
                    model.FMobile = row["FMobile"].ToString();
                }
                if (row["FMobShortNo"] != null)
                {
                    model.FMobShortNo = row["FMobShortNo"].ToString();
                }
                if (row["FEMail"] != null)
                {
                    model.FEMail = row["FEMail"].ToString();
                }
                if (row["FHomeTel"] != null)
                {
                    model.FHomeTel = row["FHomeTel"].ToString();
                }
                if (row["FHomeAddr"] != null)
                {
                    model.FHomeAddr = row["FHomeAddr"].ToString();
                }
                if (row["FSex"] != null)
                {
                    model.FSex = row["FSex"].ToString();
                }
                if (row["FIdNo"] != null)
                {
                    model.FIdNo = row["FIdNo"].ToString();
                }
                if (row["FBirthday"] != null && row["FBirthday"].ToString() != "")
                {
                    model.FBirthday = DateTime.Parse(row["FBirthday"].ToString());
                }
                if (row["FNativePlace"] != null)
                {
                    model.FNativePlace = row["FNativePlace"].ToString();
                }
                if (row["FEduNo"] != null)
                {
                    model.FEduNo = row["FEduNo"].ToString();
                }
                if (row["FSchool"] != null)
                {
                    model.FSchool = row["FSchool"].ToString();
                }
                if (row["FSpecialty"] != null)
                {
                    model.FSpecialty = row["FSpecialty"].ToString();
                }
                if (row["FSeq"] != null && row["FSeq"].ToString() != "")
                {
                    model.FSeq = int.Parse(row["FSeq"].ToString());
                }
                if (row["FPhoto"] != null && row["FPhoto"].ToString() != "")
                {
                    model.FPhoto = (byte[])row["FPhoto"];
                }
                if (row["FDutyNo"] != null)
                {
                    model.FDutyNo = row["FDutyNo"].ToString();
                }
                if (row["FJob"] != null)
                {
                    model.FJob = row["FJob"].ToString();
                }
                if (row["FEmpStatus"] != null)
                {
                    model.FEmpStatus = row["FEmpStatus"].ToString();
                }
                if (row["FLeaveDate"] != null && row["FLeaveDate"].ToString() != "")
                {
                    model.FLeaveDate = DateTime.Parse(row["FLeaveDate"].ToString());
                }
            }
            return model;
        }
    }
}
